home *** CD-ROM | disk | FTP | other *** search
/ Apple Developer Connection 1998 Fall: Game Toolkit / Disc.iso / SDKs / PCI Driver Development Kit / • Samples / Driver Samples / SCSI samples / SCSI 950629 / NCR_DriverProject / Src / InitializeInterrupts.c < prev    next >
Encoding:
C/C++ Source or Header  |  1996-08-20  |  3.1 KB  |  97 lines  |  [TEXT/MPCC]

  1. /*                                    InitializeInterrupts.c                            */
  2. /*
  3.  * InitializeInterrupts.c
  4.  * Copyright © 1994 Apple Computer Inc. All rights reserved.
  5.  *
  6.  */
  7. /*    .___________________________________________________________________________________.
  8.       | This function retrieves the interrupt-service property from the Name Registry        |
  9.       | It then installs a primary interrupt service routine and enables interrupts.        |
  10.       | It is independent of the specifics of the framework sample driver.                |
  11.     .___________________________________________________________________________________.
  12. */
  13.  
  14. #include "NCRDriverPrivate.h" 
  15.  
  16.  
  17. /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
  18.  * GetDeviceInterruptPropertyInfo retrieves the interrupt-service property information
  19.  * from the System Registry. If successful, it installs our primary interrupt service
  20.  * routine (PCIInterruptServiceRoutine)
  21.  */
  22. OSErr
  23. InstallDriverInterruptFunction(
  24.         RegEntryIDPtr            regEntryIDPtr,            /* Driver's Name Registery ID    */
  25.         InterruptHandler        interruptHandlerFunction, /* Function to install        */
  26.         InterruptSetMember        *interruptSetMemberPtr,    /* Gets interrupt set member    */
  27.         void                    **refCon,                /* Gets old RefCon                */
  28.         InterruptHandler        *oldHandlerFunction,    /* Gets old interrrupt handler    */
  29.         InterruptEnabler        *oldEnableFunction,        /* Gets old enabler                */
  30.         InterruptDisabler        *oldDisableFunction        /* Gets old disabler            */
  31.     )
  32. {
  33.         OSErr                    status;
  34.         OSStatus                osStatus;
  35.         RegPropertyValueSize    size;
  36.         StringPtr                failureMsg;
  37.  
  38.         Trace(InstallDriverInterruptFunction);
  39.         failureMsg = NULL;
  40.         size = sizeof (InterruptSetMember);
  41.         status = RegistryPropertyGet(
  42.                     regEntryIDPtr,
  43.                     kISTPropertyName,
  44.                     (RegPropertyValue *) interruptSetMemberPtr,
  45.                     &size
  46.                 );
  47.         CheckStatus(status, "\pGet interrupt set property");
  48.         if (status != noErr)
  49.             failureMsg = "\pCan't get interrupt set member";
  50.         if (status == noErr) {
  51.             /*
  52.              * Fetch the current functions for this interrupt set.
  53.              */
  54.             osStatus = GetInterruptFunctions(
  55.                         interruptSetMemberPtr->setID,
  56.                         interruptSetMemberPtr->member,
  57.                         refCon,
  58.                         oldHandlerFunction,
  59.                         oldEnableFunction,
  60.                         oldDisableFunction
  61.                     );
  62.             CheckStatus(osStatus, "\pGetInterruptFunctions");
  63.             if (osStatus != noErr) {
  64.                 status = osStatus;
  65.                 failureMsg = "\pGetInterruptFunctions failed";
  66.             }
  67.         }
  68.         if (status == noErr) {
  69.             /*
  70.              * Install our interrupt function for this set and member.
  71.              */
  72.             osStatus = InstallInterruptFunctions(
  73.                         interruptSetMemberPtr->setID,
  74.                         interruptSetMemberPtr->member,
  75.                         NULL,                            /* RefCon - ignored                */
  76.                         interruptHandlerFunction,        /* Our interrupt service func.    */
  77.                         NULL,                            /* No new interrupt enabler        */
  78.                         NULL                            /* No new interrupt disabler    */
  79.                     );
  80.             CheckStatus(osStatus, "\pInstallInterruptFunctions");
  81.             if (osStatus != noErr) {
  82.                 status = osStatus;
  83.                 failureMsg = "\pInstallInterruptFunctions failed";
  84.             }
  85.         }
  86.         if (status == noErr)                            /* Success: enable interrupts    */
  87.             (*oldEnableFunction)(*interruptSetMemberPtr, *refCon);
  88.         else {
  89.             PublishInitFailureMsg(status, failureMsg);
  90.         }
  91.         return (status);
  92. }
  93.  
  94.  
  95.  
  96.  
  97.